from . import user_blue
from flask import *
from info.models import *

#获取用户收藏
@user_blue.route('/user/user_collection')
def user_collection_handler():
    user_id = session.get('user_id')
    current_page = request.args.get('page')
    if not current_page:
        current_page = 1
    user = User.query.filter(User.id==user_id).first()
    paginate_ = user.collection_s.paginate(page=int(current_page),per_page=10)
    collections = paginate_.items
    total_page = paginate_.pages
    return render_template(
        'news/user_collection.html',
        user=user,
        collections=collections,
        total_page = total_page,
        current_page = current_page
    )